package com.lx.es.test;

import org.apache.http.HttpHost;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

/**
 * @author wcy
 */
public class ESTest_Index_Delete {

    public static void main(String[] args) throws IOException {


        //创建ES客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("114.116.253.253",9200,"http")));
        //删除索引请求对象
        DeleteIndexRequest request = new DeleteIndexRequest("user");

        // 发送请求，获取响应
        AcknowledgedResponse response = esClient.indices().delete(request,
                RequestOptions.DEFAULT);
        // 操作结果
        System.out.println("操作结果 ： " + response.isAcknowledged());

        //关闭客户端
        esClient.close();

    }

}
